package com.zb.awt;

import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class Test {

    public static void main(String[] args) {
        Frame frame = new Frame("zzz");
        Panel panel = new Panel();
        frame.setLayout(null);

        frame.setBackground(new Color(0, 100, 100));
        frame.setBounds(300, 300, 500, 500);

        panel.setBackground(new Color(0, 100, 200));
        panel.setBounds(100, 100, 300, 300);

        frame.add(panel);
        frame.setVisible(true);

        frame.addWindowListener(new WindowListener() {
            @Override
            public void windowOpened(WindowEvent e) {
                System.out.println("窗口打开");
            }

            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("窗口关闭ing");
                System.exit(0);
            }

            @Override
            public void windowClosed(WindowEvent e) {
                System.out.println("窗口关闭ed");
            }

            @Override
            public void windowIconified(WindowEvent e) {

            }

            @Override
            public void windowDeiconified(WindowEvent e) {

            }

            @Override
            public void windowActivated(WindowEvent e) {
                System.out.println("窗口激活");
            }

            @Override
            public void windowDeactivated(WindowEvent e) {
                System.out.println("窗口未激活");
            }
        });
    }
}
